<link rel="stylesheet" type="text/css" href="<?php echo $this->basePath('public/css/dbblack/js/form/style.css'); ?>"/>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/form/form.js'); ?>"></script>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/artDialog.js?skin=simple'); ?>"></script>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/artdialog/plugins/iframeTools.js'); ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo $this->basePath('public/css/dbblack/css/simple.css'); ?>"/>
<script type='text/javascript' src="<?php echo $this->basePath('public/css/dbblack/js/jquery.form.js'); ?>"></script>

<div class="container">
    <div class="order-info mt20">

        <form onsubmit="return check_step();" action="<?php if(!empty($this->payment) and !empty($this->express_array)) echo $this->url('frontcart/default', array('action'=>'submit')); ?>" method="post">
            <div class="clearfix address address-box">
                <h2><b class="fl"><?php echo $this->translate('收货地址'); ?>：</b><a class="btn btn-main btn-mini fr" href="<?php echo $this->url('frontcart/default', array('action'=>'setaddress')); ?>"><?php echo $this->translate('《重新选择收货地址'); ?></a></h2>
                <ul class="address-list clearfix">
                    <li class="selected">
                        <div class="address-info">
                            <input type="hidden" name="address_id" id="address_id" value="<?php echo $this->address_info['address_id']; ?>" />
                            <label>
                                <?php
                                $region_array = @explode(' ', $this->address_info['region_value']);
                                $region_array = array_reverse($region_array);
                                echo $this->escapeHtml(implode(', ', $region_array));
                                ?>
                                (<?php echo $this->escapeHtml($this->address_info['true_name']);?> <?php echo $this->translate('收'); ?>)</label>
                            <p>
                                <?php echo $this->escapeHtml($this->address_info['address']);?><br>
                                <?php echo $this->translate('电话'); ?>：<?php echo $this->escapeHtml($this->address_info['mod_phone']);?>
                            </p>
                        </div>
                        <i class="icon-selected-32 ie6png"></i>
                    </li>
                </ul>
            </div>

            <h2 class="f14 mt20"><?php echo $this->translate('配送方式'); ?>：</h2>
            <div class="clearfix">
                <ul class="express-list">
                    <?php if($this->express_array) foreach ($this->express_array as $express_value) { ?>
                    <li class="<?php if(isset($express_value['cash_on_delivery']) and $express_value['cash_on_delivery'] == 2) echo 'no_cash_on_delivery'; ?> <?php if(isset($express_value['selected']) and $express_value['selected'] == 1) echo 'selected'; ?>">
                    <input type="radio" name="express_id" <?php if(isset($express_value['selected']) and $express_value['selected'] == 1) echo 'checked'; ?> value="<?php echo $express_value['express_id']; ?>" onclick="calculate_fee('addpress_price_<?php echo $express_value['express_id']; ?>', 'express', '');">
                        <label><?php echo $this->escapeHtml($express_value['express_name']); ?></label>
                        <div>[ <strong><?php echo $this->translate('费用'); ?>：<?php echo $this->frontwebsite()->shopPriceSymbol(); ?> <span id="addpress_price_<?php echo $express_value['express_id']; ?>"><?php echo $this->frontwebsite()->shopPrice($express_value['express_price']); ?></span> <?php echo $this->frontwebsite()->shopPriceUnit(); ?></strong> ]&nbsp;&nbsp;<?php echo $this->escapeHtml($express_value['express_info']); ?></div>
                    </li>
                    <?php } ?>
                </ul>
            </div>

            <h2 class="f14 mt20"><?php echo $this->translate('支付方式'); ?>：</h2>
            <div class="clearfix">
                <ul class="payment-list">
                    <?php if ($this->payment) {
                    foreach($this->payment as $key => $value) {
                    ?>
                    <li <?php if(isset($value['selected']) and $value['selected'] == 1) echo 'class="selected"'; ?>><input type="radio" name="payment_code" onclick="calculate_fee('payment_price_<?php echo $value['editaction']; ?>', 'payment', '<?php echo $value['editaction']; ?>');" <?php if(isset($value['selected']) and $value['selected'] == 1) echo 'checked="checked"'; ?> value="<?php echo $value['editaction']; ?>"><label><b><?php echo $value['payment_name']['content']; ?></b> [ <strong><?php echo $this->translate('手续费'); ?>：<?php echo $this->frontwebsite()->shopPriceSymbol(); ?><span id="payment_price_<?php echo $value['editaction']; ?>"><?php echo $value['payment_fee']['content']; ?></span><?php echo $this->frontwebsite()->shopPriceUnit(); ?>
                                <?php echo ($value['editaction'] == 'yezf' ? '&nbsp;|&nbsp;' . $this->translate('余额'). '：' . $this->frontwebsite()->shopPrice($this->user_info->user_money) : ''); ?>
                            </strong> ]</label>
                        <div><img src="<?php echo $this->basePath($value['payment_logo']['content']); ?>"></div>
                    </li>
                    <?php } } ?>
                </ul>
            </div>
            <?php
            //这里是做一次优惠券的可用判断，下面多出使用即可避免重复判断
            $coupon_state = false;
            if(isset($this->use_coupon) and !empty($this->use_coupon)) $coupon_state = true;
            ?>
            <h2 class="f14 mt20"><?php echo $this->translate('商品清单'); ?>：<a class="btn btn-main btn-mini fr" href="<?php echo $this->url('frontcart/default'); ?>"><?php echo $this->translate('《返回修改购物车'); ?></a></h2>
            <div class="mt15  clearfix">
                <table width="100%" class="simple">
                    <tr>
                        <th style="width:60px;"><?php echo $this->translate('商品'); ?></th>
                        <th><?php echo $this->translate('名称'); ?></th>
                        <th><?php echo $this->translate('货号'); ?></th>
                        <th style="width:120px;"><?php echo $this->translate('规格'); ?></th>
                        <th style="width:100px;"><?php echo $this->translate('单价'); ?></th>
                        <th style="width:120px;"><?php echo $this->translate('数量'); ?></th>
                        <th style="width:100px;"><?php echo $this->translate('小计'); ?></th>
                    </tr>
                    <?php
                    $cart_integral_num = 0;//购物车中的积分购买商品数
                    foreach ($this->cart_array as $cart_key => $goods_value) {
                        $cart_integral_num = $cart_integral_num + $goods_value['integral_num'] * $goods_value['buy_num'];
                        ?>
                    <tr id="<?php echo $cart_key; ?>">
                        <td><a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['class_id'])); ?>" target="_blank"><img src="<?php echo $this->basePath($this->frontwebsite()->shopGoodsImage($goods_value['goods_image'])); ?>" width="50" height="50"></a></td>
                        <td><a href="<?php echo $this->url('frontgoods/default', array('goods_id'=>$goods_value['goods_id'], 'class_id'=>$goods_value['class_id'])); ?>" target="_blank"><?php echo $this->escapeHtml($goods_value['goods_name']); ?></a></td>
                        <td><?php echo $this->escapeHtml($goods_value['goods_item']);?></td>
                        <td>
                            <?php
                            if($goods_value['goods_color_name'] == '' and $goods_value['goods_size_name'] == '' and $goods_value['goods_adv_tag_name'] == '') {
                                echo $this->translate('无');
                            } else {
                                if(!empty($goods_value['goods_adv_tag_name'])) {
                                    echo $goods_value['goods_adv_tag_name'];
                                } else {
                                    if($goods_value['goods_color_name'] != '') echo '<p>' . $goods_value['goods_color_name'] . '</p>';
                                    if($goods_value['goods_size_name'] != '') echo '<p>' . $goods_value['goods_size_name'] . '</p>';
                                }
                            }
                            ?>
                        </td>
                        <td class="tr">
                            <?php echo $this->frontwebsite()->shopPriceExtend($goods_value['goods_shop_price']); ?>
                            <?php if(isset($goods_value['integral_num']) and $goods_value['integral_num'] > 0) { ?>
                                (<?php echo $this->translate('或').$goods_value['integral_num'].$this->translate('积分'); ?>)
                            <?php } ?>
                        </td>
                        <td class="tc">
                            <div  class="buy-num-bar buy-num clearfix"><?php echo $goods_value['buy_num']; ?></div>
                            <?php if($goods_value['goods_weight'] > 0) echo '<p>('.$this->translate('单品重:').'<strong>'.$goods_value['goods_weight'].'</strong>'.$this->translate('千克').')</p>'; ?>
                        </td>
                        <td class="amount red tc">
                            <?php echo $this->frontwebsite()->shopPriceSymbol().$this->frontwebsite()->shopPrice($goods_value['goods_shop_price'])*$goods_value['buy_num'].$this->frontwebsite()->shopPriceUnit(); ?>
                            <?php if(isset($goods_value['integral_num']) and $goods_value['integral_num'] > 0) { ?>
                                (<?php echo $this->translate('或').$goods_value['integral_num']*$goods_value['buy_num'].$this->translate('积分'); ?>)
                            <?php } ?>
                        </td>
                    </tr>
                    <?php } ?>
                </table>
                <table class="mt10 simple noborder form">
                    <tr><td>
                            <?php echo $this->translate('买家留言'); ?>：<input type="text" name="order_message" style="width:346px;">
                        </td>
                        <td width="260" class="tr"><?php echo $this->translate('购物车商品合计'); ?>：</td>
                        <td width="200" class="tr"><span class="currency-symbol f18"><?php echo $this->frontwebsite()->shopPriceSymbol(); ?></span><span class="red f18" id="goods_total_fee" total="<?php echo $this->frontwebsite()->getCartTotal(); ?>"><?php echo $this->frontwebsite()->getCartTotal(); ?></span> <?php echo $this->frontwebsite()->shopPriceUnit(); ?>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <?php
                            $shippingDateState  = $this->frontwebsite()->getOrderConfig('user_shipping_date');
                            if($shippingDateState == 'true') {
                            ?>
                            <?php echo $this->translate('送货时间'); ?>：
                            <select name="shipping_time">
                                <option value=""><?php echo $this->translate('选择送货时间'); ?></option>
                                <option value="<?php echo $this->translate('只工作日送货'); ?>"><?php echo $this->translate('只工作日送货'); ?></option>
                                <option value="<?php echo $this->translate('工作日、双休日与假日均可送货'); ?>"><?php echo $this->translate('工作日、双休日与假日均可送货'); ?></option>
                                <option value="<?php echo $this->translate('只双休日、假日送货(工作日不用送)'); ?>"><?php echo $this->translate('只双休日、假日送货(工作日不用送)'); ?></option>
                            </select>
                            <?php } ?>
                        </td>
                        <td class="tr">
                            <?php echo $this->translate('配送费用'); ?>：
                        </td>
                        <td class="tr">
                            + <span class="currency-symbol f18"><?php echo $this->frontwebsite()->shopPriceSymbol(); ?></span><span id="express_fee" class="red f18"><?php if(isset($this->express_array[0]['express_price'])) echo $this->frontwebsite()->shopPrice($this->express_array[0]['express_price']); else echo '0'; ?></span> <?php echo $this->frontwebsite()->shopPriceUnit(); ?>
                        </td>

                    </tr>
                    <tr >
                        <td>
                            <?php if(isset($GLOBALS['extendModule']['modules']) and !empty($GLOBALS['extendModule']['modules']) and in_array('Dbinvoice', $GLOBALS['extendModule']['modules'])) { ?>
                                <p style="height:32px;line-height:32px;">
                                    <?php echo $this->translate('发票抬头'); ?>：
                                    <select name="invoice_id" class="span2" style="width: 220px;">
                                        <option value=""><?php echo $this->translate('请选择'); ?></option>
                                        <?php if(!empty($this->invoice['invoice_list'])) foreach ($this->invoice['invoice_list'] as $invoiceValue) { ?>
                                            <option value="<?php echo $invoiceValue['invoice_id']; ?>"><?php echo $this->escapeHtml($invoiceValue['invoice_name']); ?></option>
                                        <?php } ?>
                                    </select>
                                    &nbsp;<a class="btn btn-main btn-mini" href="<?php echo $this->url('dbinvoice/default', array('action'=>'addTaxInvoiceCompany')); ?>" target="_blank"><?php echo $this->translate('点击添加发票抬头'); ?></a>
                                    &nbsp;<small style="color: red;"><?php echo $this->translate('新添加的信息，刷新当前页即可出现'); ?></small>
                                </p>
                            <?php } ?>
                        </td>
                        <td class="tr">
                            <?php echo $this->translate('支付手续费'); ?>：
                        </td>
                        <td class="tr">
                            + <span class="currency-symbol f18"><?php echo $this->frontwebsite()->shopPriceSymbol(); ?></span><span id="pay_fee" class="red f18"><?php if(isset($this->payment[0]['payment_fee']['content'])) echo $this->payment[0]['payment_fee']['content']; else echo '0'; ?></span> <?php echo $this->frontwebsite()->shopPriceUnit(); ?>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <?php if(isset($GLOBALS['extendModule']['modules']) and !empty($GLOBALS['extendModule']['modules']) and in_array('Dbinvoice', $GLOBALS['extendModule']['modules'])) { ?>
                                <p style="height:32px;line-height:32px;">
                                    <?php echo $this->translate('收票人'); ?>：
                                    <select name="invoice_address_id" class="span2" style="width: 220px;">
                                        <option value=""><?php echo $this->translate('请选择'); ?></option>
                                        <?php if(!empty($this->invoice['invoice_address_list'])) foreach ($this->invoice['invoice_address_list'] as $invoiceAddressValue) { ?>
                                            <option value="<?php echo $invoiceAddressValue['address_id']; ?>"><?php echo $this->escapeHtml($invoiceAddressValue['user_name']); ?></option>
                                        <?php } ?>
                                    </select>
                                    &nbsp;<a class="btn btn-main btn-mini" href="<?php echo $this->url('dbinvoice/default', array('action'=>'listInvoiceAddress')); ?>" target="_blank"><?php echo $this->translate('点击添加发票抬头'); ?></a>
                                </p>
                            <?php } else { ?>
                                <?php if ($this->frontwebsite()->websiteInfo('shop_invoice') == 'true') { ?>
                                    <p style="height:32px;line-height:32px;">
                                        <?php echo $this->translate('购物发票'); ?>：<select name="navigation_type"><option value="<?php echo $this->translate('个人发票'); ?>"><?php echo $this->translate('个人发票'); ?></option><option value="<?php echo $this->translate('公司发票'); ?>"><?php echo $this->translate('公司发票'); ?></option></select>&nbsp;&nbsp;
                                        <?php echo $this->translate('发票抬头'); ?>：<input type="text" class="span3" name="invoice_title" id="invoice_title">
                                        &nbsp;&nbsp;
                                        <?php echo $this->translate('发票内容'); ?>：<input type="text" class="span4" name="invoice_content" id="invoice_content"></span>
                                    </p>
                                <?php } ?>
                            <?php } ?>
                        </td>
                        <td class="tr">
                            <?php echo $this->translate('购买优惠'); ?>：
                        </td>
                        <td class="tr">
                            - <span class="currency-symbol f18"><?php echo $this->frontwebsite()->shopPriceSymbol(); ?></span><span id="buy_pre_fee" class="red f18"><?php echo isset($this->promotionsCost) ? $this->promotionsCost : 0; ?></span> <?php echo $this->frontwebsite()->shopPriceUnit(); ?>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <?php if(isset($GLOBALS['extendModule']['modules']) and !empty($GLOBALS['extendModule']['modules']) and in_array('Dbinvoice', $GLOBALS['extendModule']['modules'])) { ?>
                                <?php echo $this->translate('发票内容'); ?>：<input type="text" name="order_invoice_info" id="order_invoice_info" value="<?php echo $this->translate('明细'); ?>" style="width: 350px;">
                            <?php } ?>
                        </td>
                        <td class="tr">
                            <?php echo $this->translate('会员优惠'); ?>：
                        </td>
                        <td class="tr">
                            - <span class="currency-symbol f18"><?php echo $this->frontwebsite()->shopPriceSymbol(); ?></span><span id="user_pre_fee" class="red f18">0</span> <?php echo $this->frontwebsite()->shopPriceUnit(); ?>
                        </td>
                    </tr>
                    <?php if($coupon_state) { ?>
                        <tr>
                            <td >
                                <strong><?php echo $this->translate('有可用优惠券:'); ?></strong>
                                <select name="coupon_id" id="coupon_id" onchange="calculate_fee('', '', '');" class="span3">
                                    <option value="0"><?php echo $this->translate('选择优惠券'); ?></option>
                                    <?php foreach($this->use_coupon as $coupon_value) { ?>
                                        <option value="<?php echo $coupon_value['coupon_id']; ?>"><?php echo $this->escapeHtml($coupon_value['coupon_name']); ?></option>
                                    <?php } ?>
                                </select>
                                <?php foreach($this->use_coupon as $coupon_v) { ?>
                                    <input type="hidden" name="coupon_discount_value_<?php echo $coupon_v['coupon_id']; ?>" id="coupon_discount_value_<?php echo $coupon_v['coupon_id']; ?>" value="<?php echo $coupon_v['shopping_discount']; ?>">
                                <?php } ?>
                            </td>
                            <td class="tr">
                                <?php echo $this->translate('优惠券优惠'); ?>：
                            </td>
                            <td class="tr">
                                - <span class="currency-symbol f18"><?php echo $this->frontwebsite()->shopPriceSymbol(); ?></span><span id="user_coupon_fee" class="red f18">0</span> <?php echo $this->frontwebsite()->shopPriceUnit(); ?>
                            </td>
                        </tr>
                    <?php } ?>
                    <?php if ($cart_integral_num > 0) { ?>
                        <tr>
                            <td>
                                <?php if(isset($this->user_info->user_integral_num) and $this->user_info->user_integral_num > 0 and $cart_integral_num > 0) { ?>
                                    <?php echo $this->translate('使用积分购买'); ?>：<input type="text" name="integral_buy_num" id="integral_buy_num" onblur="calculate_fee('integral_buy_num', 'integral', '');" class="span2">
                                    <b><?php echo $this->translate('本订单可用').'<span id="order_integral_num">'.$cart_integral_num.'</span>'.$this->translate('消费积分'); ?></b>
                                    [<?php echo $this->translate('您拥有').' '.$this->user_info->user_integral_num.' '.$this->translate('消费积分'); ?>]
                                <?php } ?>
                            </td>
                            <td class="tr">
                                <?php echo $this->translate('积分购买'); ?>：
                            </td>
                            <td class="tr">
                                - <span class="currency-symbol f18"><?php echo $this->frontwebsite()->shopPriceSymbol(); ?></span><span id="user_integral_buy" class="red f18">0</span> <?php echo $this->frontwebsite()->shopPriceUnit(); ?>
                            </td>
                        </tr>
                    <?php } ?>
                    <?php if($this->integralInfo['integralNum'] and $this->integralInfo['integralNum'] > 0) { ?>
                    <tr>
                        <td class="tr">
                        </td>
                        <td class="tr"><?php echo $this->translate('获得消费积分'); ?>：</td>
                        <td class="tr">
                            <?php if(!empty($this->integralInfo['integalRuleInfo'])) echo '(<font color="#139EE6">' . $this->integralInfo['integalRuleInfo'] . '</font>)'; ?>：<font color="#ED145B"><?php echo $this->integralInfo['integralNum']; echo $this->translate('积分'); ?></font>
                        </td></tr>
                    <?php } ?>
                    <?php if($this->integralInfo1['integralNum'] and $this->integralInfo1['integralNum'] > 0) { ?>
                        <tr>
                            <td class="tr">
                            </td>
                            <td class="tr"><?php echo $this->translate('获得等级积分'); ?>：</td>
                            <td class="tr">
                                <?php if(!empty($this->integralInfo1['integalRuleInfo'])) echo '(<font color="#139EE6">' . $this->integralInfo1['integalRuleInfo'] . '</font>)'; ?>：<font color="#ED145B"><?php echo $this->integralInfo1['integralNum']; echo $this->translate('积分'); ?></font>
                            </td></tr>
                    <?php } ?>
                </table>
            </div>
            <div class="mb10 mt10 clearfix" style="padding:10px; background: #f0f0f0;">
                <span class="fr f14"><?php echo $this->translate('应付总额'); ?>：<span style="font-size: 24px;font-family: tahoma"><span class="currency-symbol"><?php echo $this->frontwebsite()->shopPriceSymbol(); ?></span><b class="cart-total red" id="order_total_fee"><?php echo $this->order_total; ?></b></span><?php echo $this->frontwebsite()->shopPriceUnit(); ?></span>
            </div>
            <div class=" clearfix mt10">
                <input type="hidden" id="user_pre_price" name="user_pre_price" value="0" />
                <input type="hidden" id="user_integral_price" name="user_integral_price" value="0" />
                <input type="hidden" id="buy_pre_price" name="buy_pre_price" value="<?php echo isset($this->promotionsCost) ? $this->promotionsCost : 0; ?>" />
                <input type="hidden" id="express_price" name="express_price" value="<?php if(isset($this->express_array[0]['express_price'])) echo $this->frontwebsite()->shopPrice($this->express_array[0]['express_price']); else echo '0'; ?>" />
                <input type="hidden" id="pay_price" name="pay_price" value="<?php if(isset($this->payment[0]['payment_fee']['content'])) echo $this->payment[0]['payment_fee']['content']; else echo '0'; ?>" />
                <input type="hidden" id="goods_total_price" name="goods_total_price" value="<?php echo $this->frontwebsite()->getCartTotal(); ?>" />
                <input type="hidden" id="order_total_price" name="order_total_price" value="<?php echo $this->order_total; ?>" />
                <input type="hidden" id="goods_count_weight" name="goods_count_weight" value="<?php if ($this->total_weight > 0) echo $this->total_weight; else echo 0; ?>" />

                <input type="hidden" name="step" value="step" />
                <?php if(!empty($this->payment) and !empty($this->express_array)) { ?>
                <p class=""><input type="submit" class="btn btn-main fr" value="<?php echo $this->translate('确认订单'); ?>"></p>
                <?php } ?>
            </div>
        </form>
    </div>
</div>
<script>
    $(".payment-list li").each(function(){
        /*var val_address= $('input:radio[name="payment_code"]:checked').val();
        if(val_address == '') {
            $(this).has("input[name='payment_code']:checked").addClass("selected");
        }*/
        $(this).on("click",function(){
            $(".payment-list li").removeClass("selected");
            $("input[name='payment_code']").removeProp("checked");
            $("input[name='payment_code']",this).prop("checked","checked");
            $(this).addClass("selected");

            onclick=calculate_fee('payment_price_'+$("input[name='payment_code']:checked").val(), 'payment', $("input[name='payment_code']:checked").val());
        });
    });
    $(".express-list li").each(function(){
        $(this).on("click",function(){
            $(".express-list li").removeClass("selected");
            $("input[name='express_id']").removeProp("checked");
            $("input[name='express_id']",this).prop("checked","checked");
            $(this).addClass("selected");

            calculate_fee('addpress_price_'+$("input[name='express_id']:checked").val(), 'express', '');
        });
    });
    function calculate_fee(input_id, type, paymentcode) {
        if(input_id != '') var html_price = $('#'+input_id).html();

        <?php if(isset($this->user_info->user_integral_num) and $this->user_info->user_integral_num > 0 and $cart_integral_num > 0) { ?>
        var integral_num = $('#integral_buy_num').val();
        if(integral_num == '') integral_num = 0;
        var re = /^[0-9]+.?[0-9]*$/;
        if(!re.test(integral_num)) {
            alert('<?php echo $this->translate('积分必须为数字'); ?>'); $('#'+input_id).val(0);
            integral_num = 0;
        } else {
            if(integral_num > 0) {
                if(integral_num > <?php echo $this->user_info->user_integral_num; ?>) {
                    alert('<?php echo $this->translate('输入的积分数量超过了您拥有的积分数！'); ?>');
                    $('#'+input_id).val(0);
                    integral_num = 0;
                }
                if(integral_num > <?php echo $cart_integral_num; ?>) {
                    alert('<?php echo $this->translate('输入的积分数量超过了订单中可用积分购买的最大量！'); ?>');
                    $('#'+input_id).val(0);
                    integral_num = 0;
                }

                //从这里开始，integral_num 变成了积分转换后的货币值
                integral_num = accMul(integral_num, <?php echo $this->integral_currency_con; ?>);
                var con_order_total = accAdd(parseFloat($('#order_total_price').val()), parseFloat($('#user_integral_price').val()));
                if(integral_num > con_order_total) {
                    alert('<?php echo $this->translate('输入的积分数量超过订单应付总额，请重新输入！'); ?>');
                    $('#'+input_id).val(0);
                    integral_num = 0;
                }
            }
        }
        <?php } ?>
        if(type == 'express') {
            $('#express_price').val(html_price);
            $('#express_fee').html(html_price);
        } else if (type == 'payment') {
            $('#pay_price').val(html_price);
            $('#pay_fee').html(html_price);

            if(paymentcode == 'hdfk') {
                $('.no_cash_on_delivery').css('display', 'none');
            } else {
                $('.no_cash_on_delivery').css('display', '');
            }
        } else if (type == 'integral') {//积分购买
            $('#user_integral_price').val(integral_num);
            $('#user_integral_buy').html(integral_num);
        }
        var order_total = 0;
        order_total = accAdd(order_total, parseFloat($('#express_price').val()));
        order_total = accAdd(order_total, parseFloat($('#pay_price').val()));
        order_total = accAdd(order_total, parseFloat($('#goods_total_price').val()));

        order_total = Subtr(order_total, parseFloat($('#buy_pre_price').val()));
        order_total = Subtr(order_total, parseFloat($('#user_pre_price').val()));

        <?php if(isset($this->user_info->user_integral_num) and $this->user_info->user_integral_num > 0 and $cart_integral_num > 0) { ?>
        order_total = Subtr(order_total, parseFloat($('#user_integral_price').val()));

        //对于订单可用积分的控制与显示
        var cart_integral_num = <?php echo $cart_integral_num; ?>;
        var order_integral_num = accDiv(order_total,<?php echo $this->integral_currency_con; ?>);
        if(order_integral_num > cart_integral_num) order_integral_num = cart_integral_num;
        $('#order_integral_num').html(order_integral_num);
        <?php } ?>

        <?php if($coupon_state) { ?>
        //当有优惠券可用的时候，这里才会进行处理
        var coupon_id = $('#coupon_id').val();
        if(coupon_id > 0) {
            var user_coupon_discount = parseFloat($('#coupon_discount_value_'+coupon_id).val());
            if(user_coupon_discount >= order_total) order_total = 0;
            else {
                order_total = Subtr(order_total, parseFloat(user_coupon_discount));
            }
            $('#user_coupon_fee').html(user_coupon_discount);
        }
        <?php } ?>

        order_total = advFormatNumber(order_total, 2);

        $('#order_total_price').val(order_total);
        $('#order_total_fee').html(order_total);
    }
    function check_step() {
        <?php if($this->cash_on_delivery_str != '') { ?>
        var cash_on_delivery_array = [<?php echo $this->cash_on_delivery_str; ?>];
        var payment_code = $("input[name='payment_code']:checked").val();
        var express_id = $("input[name='express_id']:checked").val();
        if(payment_code == 'hdfk' && jQuery.inArray(express_id, cash_on_delivery_array) == -1) {
            alert('<?php echo $this->translate('请选择合适的配送方式！'); ?>');
            return false;
        }
        <?php } ?>
        return true;
    }
</script>